package basis.unused;

import basis.game.fx.Particle;
import basis.game.main.Core;
import basis.game.pathfinding.NodeOverflowException;
import basis.game.pathfinding.Ω;
import basis.game.shape.Polygon2D;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Test extends Core{
    
    public static void main(String[] args){
        Test t=new Test();
        t.init();
        t.loop();
    }
    
    private ArrayList<Particle> ps;
    private int p_timer;
    private Polygon2D p;
    private double a;
    private Random r=new Random();
    private Ω path;
    
    @Override
    public void init(){
        //background=new Color(255,255,255);
        title="Test";
        super.init();
        ps=new ArrayList<Particle>();
        p=new Polygon2D(new double[]{50,100,150,100,50},new double[]{50,50,100,100,100});
        try {
            path=new Ω(10,10);
        } catch (NodeOverflowException ex) {ex.printStackTrace();}
        //path.set(2,2,21,Ω.g);
        System.out.println((path.Ø[21]>>22>>22)&Ω.I);
        System.out.println(path.getValue(1,0,Ω.I,Ω.id));
    }
    
    @Override
    public void update(long ti){
        p_timer+=ti;
        if(p_timer>=500){
            ps.add(new Particle(100,100,Math.random()*3,20,50<<16|120<<8|200));
        }
        for(Particle p:ps){
            p.update(ti);
        }
        for(int i=0;i<ps.size();i++){
            Particle p=ps.get(i);
            if(p.fade==0){
                ps.remove(p);
            }
        }
        a+=.125;
        p.setAngle(a);
    }
    
    @Override
    public void render(Graphics2D g){
        super.render(g);
        for(Particle p:ps){
            p.render(g);
        }
        p.render(g);
        g.drawString("Fps:"+fps,20,40);
    }
    
}